<?php
switch($a){
    case 'get_user_list':
        $curr_page = intval($_POST['page']);
        $curr_rows = intval($_POST['rows']);

        $records = $db->result_first("SELECT count(*) FROM `system_user`");
        $total = ceil($records/$curr_rows);

        $sql = 'SELECT * FROM `system_user` 
                ORDER BY '.($_POST['sidx'] ? $_POST['sidx'] : 'id').' '.($_POST['sord'] ? $_POST['sord']: 'asc').' 
                LIMIT '.($curr_page-1)*$curr_rows.','.$curr_rows;
        $data = $db->fetch_all($sql);
        //$User->page($curr_page.','.$curr_rows)->order(($_POST['sidx'] ? $_POST['sidx'] : 'id' ).' '.($_POST['sord'] ? $_POST['sord']: 'asc'))->select();

        $ajaxReturn = array(
            "page" => $curr_page,
            "total"=> $total,
            "records" => $records,
            "rows" => $data,
        );
        echo json_encode($ajaxReturn);
        exit();
        break;
    case 'opt_user_data':
        switch($oper){
            case 'add':
                break;
            case 'edit':
                break;
            case 'del':
                $db->query("DELETE FROM `system_user` WHERE id='".intval($id)."'");
                break;
        }
        exit();
        break;
    default:
        break;
}
?>
